/* 
  冒泡排序
*/
let bubbleSort = function (arr) {
  if (arr.length < 2) return arr;
  for (let i = arr.length; i > 0; i--) {
    for (let j = 0; j < i; j++) {
      if (arr[j] > arr[j + 1]) {
        let temp = arr[j];
        arr[j] = arr[j + 1];
        arr[j + 1] = temp;
      }
    }
  }
  return arr;
};
// let arr = [
//   12, 45, 45, 1, 721, 45, 12, 4544, 54, 45, 45, 445, 454, 5, 1212, 45, 10, 1, 1,
// ];
// let arr = [4, -47, 6, -149, 44, -70, 148, 18, 188, 217];
// let res = bubbleSort(arr);
// console.log(res);
module.exports = {
  bubbleSort,
};
